package com.sl.proxy.server.controller;


import com.sl.proxy.server.base.page.PageInfo;
import com.sl.proxy.server.base.page.PageQuery;
import com.sl.proxy.server.controller.res.system.ProtocalListRes;
import com.sl.proxy.server.service.ProtocalService;
import com.sl.proxy.server.util.ParamCheckUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: aoshiguchen
 * @date: 2023/4/2
 */
@RequestMapping("/protocal")
@RestController
@RequiredArgsConstructor
public class ProtocalController {

    private final ProtocalService protocalService;

    @GetMapping("/page")
    public PageInfo<ProtocalListRes> page(PageQuery pageQuery) {
        ParamCheckUtil.checkNotNull(pageQuery, "pageQuery");

        List<ProtocalListRes> list = protocalService.list();
        return PageInfo.of(protocalService.list(), (long) list.size(), pageQuery.getCurrent(), pageQuery.getSize());
    }

    @GetMapping("/list")
    public List<ProtocalListRes> list() {
        return protocalService.list();
    }
}
